package com.yyb.common;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 
 * 
 * 
 */
@Data
@Schema(name = "分页数据一模型")
public class PageInfo<T,Q> implements Serializable {

    @Schema(title = "页码")
    private Integer pageNumber=1;

    @Schema(title = "每页条数")
    private Integer pageSize=10;

    @Schema(title = "总条数")
    private Long totalCount;

    @Schema(title = "总页数")
    private Integer totalPage;

    @Schema(title = "分页的数据")
    private List<T> list;

    @Schema(title = "查询条件")
    private Q params;

    /**
     * 计算总页数
     */
    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
        this.totalPage=(int)Math.ceil(totalCount*1.0/this.pageSize);
    }
}
